﻿using System;
using System.Collections.Generic;
using System.Text;

namespace TbColAttribute
{
    ///　<summary>
    ///　为元素添加验证信息的特性类
    ///　</summary>
    [AttributeUsage(AttributeTargets.Property)]
    public class EntityAttribute : Attribute
    {
        ///　<summary>
        ///　验证类型
        ///　</summary>
        private ValidateType _validateType;

        ///　<summary>
        ///　最小长度
        ///　</summary>
        private int _minLength;
        ///　<summary>
        ///　最大长度
        ///　</summary>
        private int _maxLength;
        ///　<summary>
        ///　自定义数据源　
        ///　</summary>
        private string[] _customArray;
        /// <summary>
        /// 属性中文名称 验证失败使用
        /// </summary>
        private string _errorMes;        

        ///　<summary>
        ///　验证类型
        ///　</summary>
        public ValidateType ValidateType
        {
            get { return this._validateType; }
        }

        ///　<summary>
        ///　最小长度
        ///　</summary>
        public int MinLength
        {
            get { return this._minLength; }
            set { this._minLength = value; }
        }

        ///　<summary>
        ///　最大长度
        ///　</summary>
        public int MaxLength
        {
            get { return this._maxLength; }
            set { this._maxLength = value; }
        }

        ///　<summary>
        ///　自定义数据源
        ///　</summary>
        public string[] CustomArray
        {
            get { return this._customArray; }
            set { this._customArray = value; }
        }

        /// <summary>
        /// 属性中文名称 验证失败使用
        /// </summary>
        public string ErrorMes
        {
            get { return _errorMes; }
            set { _errorMes = value; }
        }

        ///　<summary>
        ///　构造函数 指定采取何种验证方式来验证元素的有效性 
        ///　</summary>
        ///　<param　name="validateType"></param>
        public EntityAttribute(ValidateType validateType)
        {
            this._validateType = validateType;
        }
    }

}
